package com.lzc.springbootrabbitmq.springbootrabbitmq.service;


import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

@Service
public class RabbitServiceImpl {
    /**
     * @param message
     * @RabbitListener(queues = "lzc")该注解 值是指定对应的队列的信息
     * 监听队列的消息，当有消息该方法就会执行进行消费
     */
    @RabbitListener(queues = "lzc")
    public void listen(Message message) {
        //获取消息体
        System.out.println(message.getBody());
        //获取消息头
        System.out.println(message.getMessageProperties());
    }
}
